package com.baseweb.webadmin.core.util;

public class PasswordUtil {
    private static char[] c = {
            'a', 'b', 'c', 'd', 'e', 'f', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
            '2', '3', '4', '5', '6', '7', '8', '9'
    };

    public static String randomPassword(int length) {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < length; i++) {
            buf.append(c[(int) Math.floor(Math.random() * c.length)]);
        }

        return buf.toString();
    }

    public static String randomPassword() {
        return randomPassword(6);
    }
}
